@echo off
chcp 65001 > nul
set MANIFEST_NAME=com.my_company.my_app
set MANIFEST_PATH=D:\bilibili-ad-blocker\liu.json

if not exist "%MANIFEST_PATH%" (
    echo Error: Manifest file not found at %MANIFEST_PATH%
    pause
    exit /b 1
)

reg add "HKCU\Software\Google\Chrome\NativeMessagingHosts\%MANIFEST_NAME%" /ve /t REG_SZ /d "%MANIFEST_PATH%" /f
if %errorlevel% equ 0 (echo [Chrome] Success) else (echo [Chrome] Failed)

reg add "HKCU\Software\Microsoft\Edge\NativeMessagingHosts\%MANIFEST_NAME%" /ve /t REG_SZ /d "%MANIFEST_PATH%" /f
if %errorlevel% equ 0 (echo [Edge] Success) else (echo [Edge] Failed)

pause